package org.rico.quartz.dynamic;

import org.quartz.JobDetail;

/**
 * Created by rico on 2017/9/25.
 */
public class JobDetailBuilder {
    private static final String DEFAULT_JOB_NAME = "";
    private static final String DEFULT_GROUP_NAME = "";

    private String jobName = DEFAULT_JOB_NAME;
    private String groupName = DEFULT_GROUP_NAME;

    private JobDetail jobDetail;
    private Class jobClazz;


    public JobDetailBuilder() {
        jobDetail = new JobDetail();
    }

    public JobDetailBuilder(String jobName, String groupName) {
        this.jobName = jobName;
        this.groupName = groupName;

        jobDetail = new JobDetail();
    }

    public JobDetailBuilder jobName(String jobName) {
        this.jobName = jobName;
        return this;
    }

    public JobDetailBuilder groupName(String groupName) {
        this.groupName = groupName;
        return this;
    }

    public JobDetailBuilder jobClazz(Class jobClazz) {
        this.jobClazz = jobClazz;
        return this;
    }

    public JobDetail build() {
        jobDetail.setGroup(groupName);
        jobDetail.setName(jobName);
        jobDetail.setJobClass(jobClazz);

        return jobDetail;
    }

}
